<?php
/* @var $this QuestionController */

$this->breadcrumbs=array(
	'Question',
);
?>
<div class="container">
   <ul class="nav-top ">
      <li>
         <a class="btn btn-danger" href="/gui-cau-hoi">Gửi câu hỏi</a>   
      </li>
   </ul>
</div>
<div class="container white-bg" id="<?php echo $this->id.'-page'?>">
   <div class="main-content">
      <div class="left">
         <?php if(count($models) > 0){?>
            
            <div class="list-quest">
               <div class="caption-label relative left"> 
                  <em class="arrow half-arrow-down sprite absolute"></em>
                  <span class="font-opensans">Danh sách câu hỏi</span>
               </div>
               <div class="clear"></div>
               <ul>
                  <?php 
                  $i = 0;
                  $question = new Question();
                  foreach($models as $model){
                     $link = $question->linkDetail($model->ques_id,$model->ques_title);
                     $i++;
                     ?>
                  <li class="ques-item">
                     <a href="<?php echo $link?>">
                        <p class="title bold font-opensans"><?php echo $model->ques_title?></p>
                     </a>
                     <div class="info">
                        <ul>
                           <li>Người gửi: <span><?php echo $model->ques_use_name?></span></li>
                           <li>Thời gian: <span><?php echo date('H:i d/m/Y',$model->ques_date_create)?></span></li>
                        </ul>
                     </div>
                     <div class="clear"></div>
                     <div class="text">
                        <div class="summary">
                           <?php echo Str::cutString(Str::removeHTML($model->ques_content),300)?>
                        </div>
                     </div>
                  </li>
                  <?php }?>
               </ul>
               <div class="right">
               <?php 
                  $pagination->render();
               ?>
               </div>
            </div>
         <?php }else{
            echo Str::notificationBox('warning','Chưa có nội dung','Cảnh báo');
         }
         ?>
         
      </div><!-- End left-content-->
      <div class="right" style="margin: 0;">
         <div class="faq" style="margin: 0;">
            <?php
               $question = new Question();
               $criteria = new CDbCriteria();
               $criteria->offset = 0;
               $criteria->limit = 10;
               $criteria->order = 'ques_id DESC';
               $list_ques = Question::model()->findAll($criteria);
            ?>
            <div class="caption uppercase text-center relative font-opensans bold"><i class="sprite absolute icon-question"></i>Hỏi đáp gần đây</div>
            <div class="list-question">
               <ul>
                  <?php foreach($list_ques as $ques){
                     $link = $ques->linkDetail($ques->ques_id,$ques->ques_title);
                     ?>
                     <li class="question-item">
                        <span class="left dots"></span>
                        <a href="<?php echo $link?>"><?php echo $ques->ques_title?></a>
                     </li>
                  <?php }?>
               </ul>
            </div>
            <div class="clear"></div>
            <div class="send-question">
               <div class="text-center bold"><span>Gửi câu hỏi của bạn tại đây</span></div>
               
                  <div class="form-faq" id="<?php echo Yii::app()->controller->id . '-' . Yii::app()->controller->action->id?>">
                     <?php $form=$this->beginWidget('CActiveForm', array(
                     	'id'=>'form_send_faq',
                        'action' => '/gui-cau-hoi',
                     	'enableAjaxValidation'=>false,
                        'enableClientValidation'=>false
                     )); ?>                     
                     
                     <div class="row">
                        <?php echo $form->error($question,'ques_use_name');?>
                        <?php echo $form->labelEx($question, 'ques_use_name');?>
                        <?php echo $form->textField($question, 'ques_use_name');?>
                     </div>  
                     <div class="row">
                        <?php echo $form->error($question,'ques_use_email');?>
                        <?php echo $form->labelEx($question, 'ques_use_email');?>   
                        <?php echo $form->textField($question, 'ques_use_email');?>
                     </div>  
                     <div class="row">
                        <?php echo $form->error($question,'ques_title');?>
                        <?php echo $form->labelEx($question, 'ques_title');?>  
                        <?php echo $form->textField($question, 'ques_title');?>
                     </div> 
                     <div class="row">
                        <?php echo $form->error($question,'ques_content');?>
                        <?php echo $form->labelEx($question, 'ques_content');?>  
                        <?php echo $form->textArea($question, 'ques_content');?>
                     </div>                     
                     <div class="row text-center relative">
                        <?php echo CHtml::submitButton('Gửi câu hỏi',array('id' => 'submit-faq'))?>
                     </div>   
                     <?php $this->endWidget(); ?>
                  </div> 
            </div>
         </div><!-- End faq -->
         
      </div><!-- End right-content -->
   </div>
</div>
<script>
   $(document).ready(function(){
      $("#slide-show").responsiveSlides({      
        speed: 800,
        nav: true,
        pager: true,
        auto:true,
      });
      
      $("#Post_order").change(function(){
         $("#form_post_order").submit();
      });
      //Load district
      $("#Post_post_prv_id").change(function(){
         var prv_id = $(this).val();
         data = {'prv_id':prv_id};
         success = function(data){
            $("#Post_post_dis_id").html(data);
         }
         handleAjax('/district/SetDropListByPrvID','GET','',data,success);
      });
      
      //Load project
      $("#Post_post_dis_id").change(function(){
         var dis_id = $(this).val();
         data = {'dis_id':dis_id};
         success = function(data){
            $("#Post_post_prj_id").html(data);
         }
         handleAjax('/project/SetDropListByDisID','GET','',data,success);
      });
   });
</script>
